package cn.wangsy.contacts;

import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;

public class Server {

	// 服务器端口号
	public static final int SERVER_PORT = 9999;
	
	public static void main(String[] args) {
		try {
			ServerSocket serverSocket = new ServerSocket(SERVER_PORT);
			Socket socket = null;
			int count = 0;// 记录客户端的数量
			while (true) {
				socket = serverSocket.accept();
				ServerThread serverThread = new ServerThread(socket);
				serverThread.start();
				count++;
				System.out.println("客户端连接的数量：" + count);
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

}
